package com.xcdh.trading.util;

import com.xcdh.commons.utils.RestTemplateUtil;
import com.xcdh.trading.query.StockPayload;
import com.xcdh.trading.response.TradingRes;

import java.util.HashMap;
import java.util.Map;

public class TuShareApi {
    private final static String url = "http://api.tushare.pro"  ;

    public static TradingRes post(String apiName){
        StockPayload payload = new StockPayload() ;
        payload.setApi_name(apiName);
        return RestTemplateUtil.post(url , payload , TradingRes.class) ;
    }

    public static TradingRes post(String apiName , String tradeDate){
        StockPayload payload = new StockPayload() ;
        payload.setApi_name(apiName);
        Map<String , Object> params = new HashMap<>() ;
        params.put("trade_date" , tradeDate) ;
        payload.setParams(params);
        return RestTemplateUtil.post(url , payload , TradingRes.class) ;
    }

}
